#include <iostream>
#include <list>
using namespace std;

int main(void)
{
    string in;
    while (getline(cin, in, '\n'))
    {
        bool f1 = false;
        bool f2 = false;
        bool f3 = false;
        bool f4 = false;
        bool f = false;
        int length = in.length();
        if (length <= 8)
        {
            cout << "NG" << endl;
            continue;
        }
        for (int i = 0; i < length; i++)
        {
            if (in.at(i) >= 'a' && in.at(i) <= 'z')
            {
                f1 = true;
            }
            else if (in.at(i) >= 'A' && in.at(i) <= 'Z')
            {
                f2 = true;
            }
            else if (in.at(i) >= '0' && in.at(i) <= '9')
            {
                f3 = true;
            }
            else
            {
                f4 = true;
            }
        }
        f = (f1 & f2 & f3) || (f1 & f2 & f4) || (f4 & f1 & f3) || (f4 & f2 & f3);
        if (f)
        {
            for (int i = 0; i < length - 5; i++)
            {
                string tmp = in.substr(i, 3);
                int ii = in.rfind(tmp);
                if (ii >= 0 && ii != i)
                {
                    cout << "NG" << endl;
                    f = false;
                    break;
                }
            }
            if (f)
                cout << "OK" << endl;
        }
        else
        {
            cout << "NG" << endl;
        }
    }

    return 0;
}
